#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define mes(x) memset(x,0,sizeof(x))
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define vec vector<int>
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int MAXN = 1e5+10;
const int inf = 0x3f3f3f3f;

int ans1;ll ans2;
int a[MAXN],dis[MAXN][8],dc[8][8],mask[MAXN],cnt[8][256],n;char s[MAXN];
vec tt[8];

void upd(int x,ll cc){if(x > ans1) ans1 = x,ans2 = 0;if(x == ans1) ans2 += cc;}

void bfs(int c){
	queue<int> q;
	for(int i = 0;i < tt[c].size();i++) {int y = tt[c][i]; q.push(y);}
	for(int i = 1;i <= n;i++) if(a[i] == c) dis[i][c] = 0;else dis[i][c] = inf;
	while(q.size()){
		int x = q.front();q.pop();if(dis[x-1][c] == inf) dis[x-1][c] = dis[x][c] + 1,q.push(x-1);
		if(dis[x+1][c] == inf) dis[x+1][c] = dis[x][c] + 1,q.push(x+1);
	}
}

int main (){
	memset(dc,0x3f,sizeof(dc));
	n = in;scanf("%s",s+1);for(int i = 1;i <= n;i++) a[i] = s[i]-'a',tt[a[i]].pb(i);
	for(int i = 0;i < 8;i++) bfs(i),dc[i][i] = 0;
	for(int i = 1;i <= n;i++)
		for(int j = 0;j < 8;j++)
			for(int k = 0;k < 8;k++)
				dc[j][k] = min(dc[j][k],dis[i][j] + dis[i][k]);
	for(int k = 0;k < 8;k++)
		for(int i = 0;i < 8;i++)
			for(int j = 0;j < 8;j++)
				dc[i][j] = min(dc[i][j],dc[i][k]+dc[k][j]+1);
	for(int i = 1;i <= n;i++)
		for(int j = 0;j < 8;j++)
			for(int k = 0;k < 8;k++)
				dis[i][j] = min(dis[i][j],dis[i][k] + dc[k][j] + 1);
	for(int i = 1;i <= n;i++)
		for(int k = 0;k < 8;k++)
			mask[i] |= (dis[i][k] - dc[a[i]][k]) << k;
	for(int r = 2;r <= n;r++)
		for(int l = max(1,r - 15);l < r;l++){
			int dd = r-l;
			for(int i = 0;i < 8;i++)
				dd = min(dd,dis[l][i] + dis[r][i] + 1);
			upd(dd,1);
		}
	for(int r = 17,l = 1;r <= n;l++,r++){
		cnt[a[l]][mask[l]]++;
		for(int aj = 0;aj < 8;aj++)
			for(int msk = 0;msk < 256;msk++)
				if(cnt[aj][msk]){
					int dd = inf;
					for(int k = 0;k < 8;k++)
						dd = min(dis[r][k]+dc[aj][k] + ((msk >> k)&1) + 1,dd);
					upd(dd,cnt[aj][msk]);
				}
	}
	printf("%d %lld\n",ans1,ans2);
	return 0;
}

